from machine import ADC


class Trimpot:
    """电位器
    微调可变电阻
    """
    def __init__(self, pin) -> None:
        adc = ADC(pin)
        adc.atten(ADC.ATTN_11DB)
        adc.width(ADC.WIDTH_12BIT)
        self.__pin = adc

    def read_analog(self):
        return self.__pin.read()


if __name__ == "__main__":
    import time

    tr = Trimpot(14)

    while True:
        print(tr.read_analog())
        time.sleep(2)
